package com._520it.crm.service.impl;

import com._520it.crm.domain.Employee;
import com._520it.crm.mapper.EmployeeMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.EmployeeQueryObject;
import com._520it.crm.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @描述:
 * @作者:瓜
 * @create 2020/11/4
 */
@Service
public class EmployeeServiceImpl implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeDao;

    public int deleteByPrimaryKey(Long id) {
        return employeeDao.deleteByPrimaryKey(id);
    }
    public int insert(Employee record) {
        return employeeDao.insert(record);
    }
    public Employee selectByPrimaryKey(Long id) {
        return employeeDao.selectByPrimaryKey(id);
    }
    public List<Employee> selectAll() {
        return employeeDao.selectAll();
    }
    public int updateByPrimaryKey(Employee record) {
        return employeeDao.updateByPrimaryKey(record);
    }
    public Employee getEmployeeServiceFindLogin(String username, String password) {
        return employeeDao.getEmployeeServiceFindLogin(username,password);
    }

    public PageResult queryForPage(EmployeeQueryObject qo) {
        //查询总记录数
        Long count=employeeDao.queryForPageCount(qo);
        if (count == 0) {
            return new PageResult(0,Collections.EMPTY_LIST);
        }

        //查询总结果集
        List result=employeeDao.queryForPage(qo);
        return new PageResult(count.intValue(),result);
    }

    @Override
    public void updateState(Long id) {
        employeeDao.updateState(id);
    }
}
